package cn.com.code.generator.thread;

import cn.com.do1.dsf.common.utils.SpringContextUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.UUID;
import java.util.concurrent.Callable;

/**
 * @ClassName: DefaultExecutionTask
 * @Author: huangrenhao
 * @Description:
 * @CreateTime： 2020/7/12 0012 下午 2:59
 * @Version：
 **/
@Slf4j
public class DefaultExecutionTask implements Callable<Integer> {

    private List<Integer> list;

    private MultiEndFlag endFlag;

    private UUID threadId;

    private ThreadExecution execution;

    private CommonThreadExecutionService commonThreadExecutionService;

    public DefaultExecutionTask(MultiEndFlag endFlag, List list, ThreadExecution execution) {
        this.list = list;
        this.endFlag = endFlag;
        this.threadId = UUID.randomUUID();
        this.execution = execution;
        commonThreadExecutionService = SpringContextUtils.getBean(CommonThreadExecutionService.class);
    }

    @Override
    public Integer call() throws Exception {
        commonThreadExecutionService.executeBatch(execution, endFlag, threadId, list);
        return 0;
    }
}
